import sys
from PyQt5.QtWidgets import QApplication, QWidget, QFrame, QVBoxLayout, QLabel, QHBoxLayout
from PyQt5.QtCore import Qt


class CardExample(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        # 创建一个QFrame作为卡片
        card = QFrame(self)
        card.setStyleSheet("""
            QFrame {
                background-color: #FFF;
                border-radius: 10px;
                padding: 10px;
            }
        """)
        card.setFrameShape(QFrame.StyledPanel)

        label1 = QLabel("看下效果")
        hLayout = QHBoxLayout()
        hLayout.addWidget(label1)
        card.setLayout(hLayout)
        # 将卡片布局添加到窗口中
        vbox = QVBoxLayout()
        vbox.addWidget(card)
        self.setLayout(vbox)

        self.setGeometry(100, 100, 300, 200)
        self.setWindowTitle('Card Example')
        self.show()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = CardExample()
    sys.exit(app.exec_())